package com.example.dao.impl;

import com.example.dao.UserDao;
import com.example.entity.IndexInfo;
import com.example.entity.Resource;
import com.example.entity.User;
import com.example.utils.BaseDao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class UserDaoImpl implements UserDao {
    @Override
    public User selectByUserName(String username) {
        Object[]objects=new Object[1];
        objects[0]=username;
        ResultSet resultSet = BaseDao.select("select *from user where username=?", objects);
        try {
            while (resultSet.next()){
                User user=new User();
                user.setUsername(resultSet.getString("username"));
                user.setPassword(resultSet.getString("password"));
                return user;
            }
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        return null;
    }
}
